package com.leetcode.leetcode1;

/**
 * @program: 盛最多水的容器
 * @author: luhd
 * @create: 2021-08-22
 */
public class Practice11 {
    public static void main(String[] args) {
        int[] arr = {1,2,1};
        int i = maxArea(arr);
        System.out.println(i);
    }
    public static int maxArea(int[] height) {
        int len = height.length;
        int first = 0;
        int last = len -1;
        int maxArea = 0;
        while(first<last){
            maxArea = Math.min(height[first],height[last])*(last - first)>maxArea?Math.min(height[first],height[last])*(last - first):maxArea;
            if(height[first]<height[last]){
                first++;
            }else{
                last--;
            }
        }
        return maxArea;
    }
}
